package cn.zcy.springboot_springsecurity02.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin")
public class Admin2Controller {
    @GetMapping("/hello")
    public String admin() {
        String username = SecurityContextHolder.getContext().getAuthentication().getName();
        System.out.println(username);
        System.out.println("springboot");
        return "springSecurity=" + username;
    }

    @GetMapping("/user/index")
    public String login() {

        System.out.println("index登录成功");
        return "登录成功";
    }
}
